package com.example.service.impl;

import com.example.mapper.GuestMapper;
import com.example.pojo.Book;
import com.example.pojo.Guest;
import com.example.service.GuestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 名称GuestServiceImpl
 * 描述discribe GuestService
 *
 * @version 1.0
 * @author:wanghao
 * @datatime:2023,04,16,16,36
 */
@Service
@Primary
public class GuestServiceImpl implements GuestService {
    @Autowired
    GuestMapper guestMapper;

    @Override
    public String CheckGuestPasswd(String name,String passwd){
        Guest guest = guestMapper.CheckGuestLogin(name);
        if (guest!=null){
            if (guest.getPasswd().equals(passwd)){
                return "true";
            }
            else return "wrong passwd";
        }
        else return "not exist";
    }

    @Override
    public Integer InsertGuest(Guest guest){return guestMapper.InsertGuest(guest);}

    @Override
    public Book FindBookByID(Integer ID){return guestMapper.FindBookByID(ID);}

    @Override
    public List<Book> FindBookByStr(String searchStr){return guestMapper.FindBookByStr(searchStr);}

    @Override
    public List<Book> FindAllBook() {
        return guestMapper.FindAllBook();
    }

//    @Override
//    public String FindBookStatusByID(Integer ID){
//        Book book = guestMapper.FindBookByID(ID);
//        String Y = String.valueOf('Y');
//        if (book!=null)
//        {
//            System.out.println(book.getStatus());
//            if (book.getStatus().equals(Y))   return "true";
//            else return "false";
//        }
//        else return "something wrong";
//    }

    @Override
    public Integer UpdateBook(Book book){
        return guestMapper.UpdateBook(book);
    }
}
